//
//  MessageRedVM.swift
//  Pods
//
//  Created by eme on 2017/4/10.
//
//

import UIKit
import RxSwift
import ModelProtocol

class MessageRedVM{
    
    let messageRed = PublishSubject<String>()
    let error = PublishSubject<MikerError>()
    let result = PublishSubject<Bool>()
    
    let disposeBag = DisposeBag()
    
    init(){
        
        let request = messageRed.map{ id in
            return MineApi.messageRed(mid: id)
            }.shareReplay(1)
        
        
        let response = request.emeRequestApiForRegJson().shareReplay(1)
        
        response.subscribe(onNext:{ result in
            switch result{
            case .failure(let error):
                self.error.onNext(error)
            case .success(_):
                self.result.onNext(true)
            }
        }).addDisposableTo(disposeBag)
    }
    
}
